/*
 * Copyright 2011 Angel Sanadinov
 *
 * This file is part of VBox WMI.
 *
 * VBox WMI is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VBox WMI is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VBox WMI.  If not, see <http://www.gnu.org/licenses/>.
 */

package Beans.Requests.MachineManagement.Components;

/**
 * This class represents the settings of a shared folder on a virtual machine.
 *
 * @author Angel Sanadinov
 */
public class SharedFolderSettings extends MachineManagementComponent
{
    private String name;            //shared folder name
    private String hostPath;        //shared folder path on the host
    private boolean isWritable;     //is the folder read+write
    private boolean isAccessible;   //is the folder accessible
    private String lastAccessError; //last access error, if available

    /**
     * Constructs a shared folder settings object with the specified data. <br><br>
     *
     * Usually used when creating or modifying folders.
     *
     * @param name the name of the shared folder
     * @param hostPath the shared folder path on the host system
     * @param isWritable is the folder writable
     */
    public SharedFolderSettings(String name, String hostPath, boolean isWritable)
    {
        this.name = name;
        this.hostPath = hostPath;
        this.isWritable = isWritable;
    }

    /**
     * Constructs a shared folder settings object with the specified data. <br><br>
     *
     * Usually used when retrieving shared folder data.
     *
     * @param name the name of the shared folder
     * @param hostPath the shared folder path on the host system
     * @param isWritable is the folder writable
     * @param isAccessible the accessibility of the folder
     * @param lastAccessError last accessibility error
     */
    public SharedFolderSettings(String name, String hostPath, boolean isWritable,
                                boolean isAccessible, String lastAccessError)
    {
        this(name, hostPath, isWritable);
        this.isAccessible = isAccessible;
        this.lastAccessError = lastAccessError;
    }

    /**
     * Retrieves the name of the shared folder.
     *
     * @return the shared folder name
     */
    public String getName()
    {
        return name;
    }

    /**
     * Retrieves the shared folder path on the host system.
     *
     * @return the shared folder host path
     */
    public String getHostPath()
    {
        return hostPath;
    }

    /**
     * Retrieves the writability of the shared folder.
     *
     * @return <code>true</code> if the folder has read + write permissions or
     *         <code>false</code> if only read permissions are available
     */
    public boolean getIsWritable()
    {
        return isWritable;
    }

    /**
     * Retrieves the accessibility state of the shared folder.
     *
     * @return <code>true</code> if the shared folder is accessible or <code>false</code>
     *         if it is not
     */
    public boolean getIsAccessible()
    {
        return isAccessible;
    }

    /**
     * Retrieves the last access error that was encountered.
     *
     * @return the last access error
     */
    public String getLastAccessError()
    {
        return lastAccessError;
    }

    @Override
    public boolean isValid()
    {
        if(name != null && hostPath != null)
            return true;
        else
            return false;
    }
}
